home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-30 | 13.4 KB | 559 lines | [TEXT/CWIE] |
- { Checkboxes.p }
- { Created 10/30/98 1:06 PM by AppMaker }
-
- Unit Checkboxes;
- Interface
-
- Uses
- Types,
- Quickdraw,
- Controls,
- Dialogs,
- Events,
- Lists,
- Menus,
- Resources,
- TextEdit,
- ToolUtils,
-
- DDocData,
- EverythingEngine,
- EverythingDoc,
- AMWindow;
-
- type
- Checkboxes = object (AMWindow)
-
- {data members}
- mData: DDocData;
- mStandard2Handle: ControlHandle;
- mXxHandle: ControlHandle;
- mCapTriangleLabel: ControlHandle;
- mGraphic2Handle: ControlHandle;
- mCapcicn2Label: ControlHandle;
- mLRHandle: ControlHandle;
- mCapicl10Label: ControlHandle;
- mLR2Handle: ControlHandle;
- mCapICN2Label: ControlHandle;
- mLR3Handle: ControlHandle;
- mCapPICT2Label: ControlHandle;
- mLR4Handle: ControlHandle;
- mCheckboxHandle: ControlHandle;
- mCapicl11Label: ControlHandle;
- mBevel2Handle: ControlHandle;
- mCheckbox2Handle: ControlHandle;
- mNext3Handle: ControlHandle;
- mNext4Handle: ControlHandle;
-
- {methods}
- Procedure Initialize; Override;
-
- Procedure Open (inDoc: EverythingDoc;
- inData: DDocData);
- Procedure Close; Override;
-
- Procedure Control (whichControl: ControlHandle;
- whichPart: integer;
- where: Point); Override;
- Procedure MouseIn (where: Point;
- modifiers: integer); Override;
- Procedure TypeIn (charCode: SInt16); Override;
- Procedure ExitCurField; Override;
- Procedure DataChanged (inDataID: longint); Override;
- Procedure Resize; Override;
- Procedure Scroll (newValue: integer;
- oldValue: integer); Override;
-
- Function GetEngine: EverythingEngine;
-
- {$ifc false}
- Procedure UpdateMenus; Override;
- {$endif}
- Function DoCommand (inCommand: longint): Boolean; Override;
-
- Procedure DoUndo;
- Procedure DoCut;
- Procedure DoCopy;
- Procedure DoPaste;
- Procedure DoClear;
- Procedure DoSelectAll;
- Procedure DoShowClipboard;
-
- end;
-
- {----------}
- Procedure CreateCheckboxes (inDoc: EverythingDoc;
- inData: DDocData);
-
- {----------}
- Implementation
-
- Uses
- Globals,
- ResourceDefs,
- DoScrap,
- Scrolling,
- ControlUtils,
- Miscellany;
-
- const
- kStandard2Check = 1;
- kXxCheck = 2;
- kCapTriangleLabel = 3;
- kGraphic2Box = 4;
- kCapcicn2Label = 5;
- kLRCheck = 6;
- kCapicl10Label = 7;
- kLR2Check = 8;
- kCapICN2Label = 9;
- kLR3Check = 10;
- kCapPICT2Label = 11;
- kLR4Check = 12;
- kCheckboxCheck = 13;
- kCapicl11Label = 14;
- kBevel2Box = 15;
- kCheckbox2Check = 16;
- kNext3Check = 17;
- kNext4Check = 18;
-
- {----------}
- Procedure CreateCheckboxes (
- inDoc: EverythingDoc;
- inData: DDocData);
- var
- winObj: Checkboxes;
- begin
- winObj := nil;
- New (winObj);
-
- if winObj <> nil then begin
- winObj.Initialize;
- winObj.Open (inDoc, inData);
- end;
- end;
-
- {----------}
- Procedure Checkboxes.Initialize;
- begin
- Inherited Initialize;
- end;
-
- {----------}
- Function Checkboxes.GetEngine: EverythingEngine;
- begin
- GetEngine := EverythingEngine (mDoc.mEngine);
- end;
-
- {----------}
- Procedure Checkboxes.Open (
- inDoc: EverythingDoc;
- inData: DDocData);
- var
- window: WindowPtr;
- wftb: Handle;
- errCode: OSErr;
- begin
- mDoc := inDoc;
- mData := inData;
- mData.AddResponder (self);
-
- window := GetNewCWindow (WIND_Checkboxes, nil, WindowPtr (-1));
- if inDoc.mEngine.GetFilename <> '' then begin
- SetWTitle (window, inDoc.mEngine.GetFilename);
- end;
- mWindow := window;
- EverythingDoc (mDoc).mCheckboxesPtr := window;
-
- WindowPeek (window)^.windowKind := kAMWindowFlag;
- SetWRefCon (window, ord4 (self));
- SetPort (window);
- SetInfo (window);
-
- wftb := GetResource ('Wftb', WIND_Checkboxes);
-
- errCode := CreateRootControl (window, mRootControl);
-
- vScroll := nil;
- hScroll := nil;
-
-
- mStandard2Handle := GetNewControl (CNTL_Standard2, window);
- SetWindowItemFont (mStandard2Handle, wftb, 1);
- SetControlValue (mStandard2Handle, ord (mData.GetStandard));
-
- mXxHandle := GetNewControl (CNTL_Xx, window);
- SetWindowItemFont (mXxHandle, wftb, 2);
- SetControlValue (mXxHandle, ord (mData.GetXx));
-
- mCapTriangleLabel := GetNewControl (CNTL_CapTriangle, window);
- SetWindowItemFont (mCapTriangleLabel, wftb, 3);
- SetControlFromTEXT (mCapTriangleLabel, TEXT_CapTriangle);
-
- mGraphic2Handle := GetNewControl (CNTL_Graphic2, window);
- SetWindowItemFont (mGraphic2Handle, wftb, 4);
-
- mCapcicn2Label := GetNewControl (CNTL_Capcicn2, window);
- errCode := EmbedControl (mCapcicn2Label, mGraphic2Handle);
- SetWindowItemFont (mCapcicn2Label, wftb, 5);
- SetControlFromTEXT (mCapcicn2Label, TEXT_Capcicn2);
-
- mLRHandle := GetNewControl (CNTL_LR, window);
- errCode := EmbedControl (mLRHandle, mGraphic2Handle);
- SetWindowItemFont (mLRHandle, wftb, 6);
- SetControlValue (mLRHandle, ord (mData.GetLR));
-
- mCapicl10Label := GetNewControl (CNTL_Capicl10, window);
- errCode := EmbedControl (mCapicl10Label, mGraphic2Handle);
- SetWindowItemFont (mCapicl10Label, wftb, 7);
- SetControlFromTEXT (mCapicl10Label, TEXT_Capicl10);
-
- mLR2Handle := GetNewControl (CNTL_LR2, window);
- errCode := EmbedControl (mLR2Handle, mGraphic2Handle);
- SetWindowItemFont (mLR2Handle, wftb, 8);
- SetControlValue (mLR2Handle, ord (mData.GetLR2));
-
- mCapICN2Label := GetNewControl (CNTL_CapICN2, window);
- errCode := EmbedControl (mCapICN2Label, mGraphic2Handle);
- SetWindowItemFont (mCapICN2Label, wftb, 9);
- SetControlFromTEXT (mCapICN2Label, TEXT_CapICN2);
-
- mLR3Handle := GetNewControl (CNTL_LR3, window);
- errCode := EmbedControl (mLR3Handle, mGraphic2Handle);
- SetWindowItemFont (mLR3Handle, wftb, 10);
- SetControlValue (mLR3Handle, ord (mData.GetLR3));
-
- mCapPICT2Label := GetNewControl (CNTL_CapPICT2, window);
- errCode := EmbedControl (mCapPICT2Label, mGraphic2Handle);
- SetWindowItemFont (mCapPICT2Label, wftb, 11);
- SetControlFromTEXT (mCapPICT2Label, TEXT_CapPICT2);
-
- mLR4Handle := GetNewControl (CNTL_LR4, window);
- errCode := EmbedControl (mLR4Handle, mGraphic2Handle);
- SetWindowItemFont (mLR4Handle, wftb, 12);
- SetControlValue (mLR4Handle, ord (mData.GetLR4));
-
- mCheckboxHandle := GetNewControl (CNTL_Checkbox, window);
- errCode := EmbedControl (mCheckboxHandle, mGraphic2Handle);
- SetWindowItemFont (mCheckboxHandle, wftb, 13);
- SetControlValue (mCheckboxHandle, ord (mData.GetCheckbox));
-
- mCapicl11Label := GetNewControl (CNTL_Capicl11, window);
- errCode := EmbedControl (mCapicl11Label, mGraphic2Handle);
- SetWindowItemFont (mCapicl11Label, wftb, 14);
- SetControlFromTEXT (mCapicl11Label, TEXT_Capicl11);
-
- mBevel2Handle := GetNewControl (CNTL_Bevel2, window);
- SetWindowItemFont (mBevel2Handle, wftb, 15);
-
- mCheckbox2Handle := GetNewControl (CNTL_Checkbox2, window);
- errCode := EmbedControl (mCheckbox2Handle, mBevel2Handle);
- SetWindowItemFont (mCheckbox2Handle, wftb, 16);
- SetControlValue (mCheckbox2Handle, ord (mData.GetCheckbox2));
- errCode := SetBevelButtonGraphicAlignment (mCheckbox2Handle, kControlBevelButtonAlignCenter, 0, 0);
-
- mNext3Handle := GetNewControl (CNTL_Next3, window);
- errCode := EmbedControl (mNext3Handle, mBevel2Handle);
- SetWindowItemFont (mNext3Handle, wftb, 17);
- SetControlValue (mNext3Handle, ord (mData.GetNext));
- errCode := SetBevelButtonTextPlacement (mNext3Handle, kControlBevelButtonPlaceToRightOfGraphic);
- errCode := SetBevelButtonTextAlignment (mNext3Handle, kControlBevelButtonAlignTextFlushLeft, 0);
- errCode := SetBevelButtonGraphicAlignment (mNext3Handle, kControlBevelButtonAlignLeft, 0, 0);
-
- mNext4Handle := GetNewControl (CNTL_Next4, window);
- errCode := EmbedControl (mNext4Handle, mBevel2Handle);
- SetWindowItemFont (mNext4Handle, wftb, 18);
- SetControlValue (mNext4Handle, ord (mData.GetNext2));
- errCode := SetBevelButtonTextPlacement (mNext4Handle, kControlBevelButtonPlaceBelowGraphic);
- errCode := SetBevelButtonTextAlignment (mNext4Handle, kControlBevelButtonAlignTextCenter, 0);
- errCode := SetBevelButtonGraphicAlignment (mNext4Handle, kControlBevelButtonAlignTop, 0, 0);
-
- errCode := AdvanceKeyboardFocus (window);
-
- ShowWindow (window);
- end;
-
- {----------}
- Procedure Checkboxes.Close;
- begin
- mData.RemoveResponder (self);
-
- EverythingDoc (mDoc).mCheckboxesPtr := nil;
- SetInfo (nil);
- HideWindow (mWindow);
- DisposeWindow (mWindow);
-
- Dispose (self);
- end;
-
- {----------}
- Procedure Checkboxes.Control (
- whichControl: ControlHandle;
- whichPart: integer;
- where: Point);
- var
- bounds: Rect;
- newValue: integer;
- partcode: SInt16;
- begin
- ExitCurField ();
-
- if whichControl = mStandard2Handle then begin
- if TrackCheckbox (mStandard2Handle, where) then begin
- mData.SetStandard (GetControlValue (mStandard2Handle) <> 0);
- end;
- end;
- if whichControl = mXxHandle then begin
- if TrackCheckbox (mXxHandle, where) then begin
- mData.SetXx (GetControlValue (mXxHandle) <> 0);
- end;
- end;
- if whichControl = mLRHandle then begin
- if TrackCheckbox (mLRHandle, where) then begin
- mData.SetLR (GetControlValue (mLRHandle) <> 0);
- end;
- end;
- if whichControl = mLR2Handle then begin
- if TrackCheckbox (mLR2Handle, where) then begin
- mData.SetLR2 (GetControlValue (mLR2Handle) <> 0);
- end;
- end;
- if whichControl = mLR3Handle then begin
- if TrackCheckbox (mLR3Handle, where) then begin
- mData.SetLR3 (GetControlValue (mLR3Handle) <> 0);
- end;
- end;
- if whichControl = mLR4Handle then begin
- if TrackCheckbox (mLR4Handle, where) then begin
- mData.SetLR4 (GetControlValue (mLR4Handle) <> 0);
- end;
- end;
- if whichControl = mCheckboxHandle then begin
- if TrackCheckbox (mCheckboxHandle, where) then begin
- mData.SetCheckbox (GetControlValue (mCheckboxHandle) <> 0);
- end;
- end;
- if whichControl = mCheckbox2Handle then begin
- if TrackClick (mCheckbox2Handle, where) then begin
- mData.SetCheckbox2 (GetControlValue (mCheckbox2Handle) <> 0);
- end;
- end;
- if whichControl = mNext3Handle then begin
- if TrackClick (mNext3Handle, where) then begin
- mData.SetNext (GetControlValue (mNext3Handle) <> 0);
- end;
- end;
- if whichControl = mNext4Handle then begin
- if TrackClick (mNext4Handle, where) then begin
- mData.SetNext2 (GetControlValue (mNext4Handle) <> 0);
- end;
- end;
- end;
-
- {----------}
- Procedure Checkboxes.DataChanged (
- inDataID: longint);
- begin
- if inDataID = idStandard then begin
- SetControlValue (mStandard2Handle, ord (mData.GetStandard));
- end;
- if inDataID = idXx then begin
- SetControlValue (mXxHandle, ord (mData.GetXx));
- end;
- if inDataID = idLR then begin
- SetControlValue (mLRHandle, ord (mData.GetLR));
- end;
- if inDataID = idLR2 then begin
- SetControlValue (mLR2Handle, ord (mData.GetLR2));
- end;
- if inDataID = idLR3 then begin
- SetControlValue (mLR3Handle, ord (mData.GetLR3));
- end;
- if inDataID = idLR4 then begin
- SetControlValue (mLR4Handle, ord (mData.GetLR4));
- end;
- if inDataID = idCheckbox then begin
- SetControlValue (mCheckboxHandle, ord (mData.GetCheckbox));
- end;
- if inDataID = idCheckbox2 then begin
- SetControlValue (mCheckbox2Handle, ord (mData.GetCheckbox2));
- end;
- if inDataID = idNext then begin
- SetControlValue (mNext3Handle, ord (mData.GetNext));
- end;
- if inDataID = idNext2 then begin
- SetControlValue (mNext4Handle, ord (mData.GetNext2));
- end;
- End;
-
- {----------}
- Procedure Checkboxes.MouseIn (
- where: Point;
- modifiers: integer);
- var
- bounds: Rect;
- begin
- end;
-
- {----------}
- Procedure Checkboxes.ExitCurField;
- var
- errCode: OSErr;
- focus: ControlHandle;
- begin
- errCode := GetKeyboardFocus (mWindow, focus);
-
- if focus = nil then begin
- { nothing to exit }
-
- end;
- inherited ExitCurField;
- end;
-
- {----------}
- Procedure Checkboxes.TypeIn (
- charCode: SInt16);
- var
- ch: char;
- errCode: OSErr;
- focus: ControlHandle;
- keyCode: SInt16;
- partcode: SInt16;
- begin
- errCode := GetKeyboardFocus (mWindow, focus);
-
- ch := chr (charCode);
- if (ch = charEnter)
- | (ch = charReturn) then begin
- ExitCurField;
- end else if ch = charEsc then begin
- end else if ch = charTab then begin
- DoTab (BAnd (curEvent.modifiers, optionKey) <> 0);
- end else if focus <> nil then begin
- keyCode := BAnd (curEvent.message, keyCodeMask);
- partcode := HandleControlKey (focus, keyCode, charCode, curEvent.modifiers);
- mDoc.mEngine.SetDirty;
- end else begin
- SysBeep (1);
- end;
- end;
-
- {----------}
- Procedure Checkboxes.Resize;
- begin
- { application-specific code to resize items in window }
- end;
-
- {----------}
- Procedure Checkboxes.Scroll (
- newValue: integer;
- oldValue: integer);
- begin
- { application-specific code to scroll window }
- if gWhichScroll = vScroll then begin
- end else begin { horizontal }
- end;
- end;
-
- {----------}
- Procedure Checkboxes.DoUndo;
- begin
- end; {DoUndo}
-
- {----------}
- Procedure Checkboxes.DoCut;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TECut (curTE);
- mDoc.mEngine.SetDirty;
- scrapDirty := true;
- end;
- end; {DoCut}
-
- {----------}
- Procedure Checkboxes.DoCopy;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TECopy (curTE);
- scrapDirty := true;
- end;
- end; {DoCopy}
-
- {----------}
- Procedure Checkboxes.DoPaste;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TEPaste (curTE);
- mDoc.mEngine.SetDirty;
- end;
- end; {DoPaste}
-
- {----------}
- Procedure Checkboxes.DoClear;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TEDelete (curTE);
- mDoc.mEngine.SetDirty;
- end;
- end; {DoClear}
-
- {----------}
- Procedure Checkboxes.DoSelectAll;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TESetSelect (0, 32767, curTE);
- end;
- end; {DoSelectAll}
-
- {----------}
- Procedure Checkboxes.DoShowClipboard;
- begin
- end; {DoShowClipboard}
-
- {----------}
- Function Checkboxes.DoCommand (
- inCommand: longint): Boolean;
- begin
- DoCommand := true;
- case inCommand of
- cmdUndo:
- DoUndo;
- cmdCut:
- DoCut;
- cmdCopy:
- DoCopy;
- cmdPaste:
- DoPaste;
- cmdClear:
- DoClear;
- cmdSelectAll:
- DoSelectAll;
- cmdShowClipboard:
- DoShowClipboard;
-
- otherwise
- DoCommand := false;
- end; {case}
- end;
-
- end.
-